<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<script src="./vue2.js"></script>
<body>
    <div id="box">
        <navbar @navevent="handleEvent"></navbar>
        <sidebar v-show="isShow"></sidebar>
    </div>
    <script>
        Vue.component("navbar",{
            template:`<div style="background-color:green">
                    <button @click="handleClick">点击</button>
                    </div>`,
            methods:{
                handleClick(){
                    this.$emit("navevent")
                }
            }
        },   
        )
        Vue.component("sidebar",{
            template:`<div style="background-color:yellow">
                        <ul>
                            <li>111</li>
                            <li>111</li>
                            <li>111</li>
                            <li>111</li>
                            <li>111</li>
                            <li>111</li>
                            <li>111</li>
                        </ul>
                    </div>`
        })
        new Vue({
            el:'#box',
            data:{
                isShow:false
            },
            methods:{
                handleEvent(){
                    this.isShow=!this.isShow
                }
            }
        })
    </script>
</body>
</html>